import React from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import './App.css';
import { Home } from './pages/home/index'
import { Login } from './pages/login/index';
import { My } from './pages/my/index';
import { Category } from './pages/category/index';
import { Cart } from './pages/cart/index';
import './styles/rem.less'
import 'bootstrap/dist/css/bootstrap.min.css';
import { UserAuthRoute } from './middleware/UserAuthMiddleware';
// import { Login } from './pages/login/index'
// const Home = () => <div>主页</div>
const Article = () => <div>文章列表页</div>
const ArticleDetail = () => <div>文章详情页</div>


// const Login = () => <div>登录页面</div>

// const loginFlag = false;

// if(! loginFlag){
//   <Redirect to={{pathname:"/login"}} />
// }


function App() {
  return (
    <Router>
      {/* exact 去除非根目录的匹配 */}
      <Route path="/" exact component={Home} />
      <Route path="/home" component={Home} />
      <UserAuthRoute path="/article" component={Article} />
      <UserAuthRoute path="/article/123" component={ArticleDetail} />
      <Route path="/login" component={Login} />
      <Route path="/my" component={My} />
      <Route path="/category" component={Category} />
      <Route path="/cart" component={Cart} />
    </Router>
  );
}

export default App;
